﻿$(function(){
    var queryString = nehnre.queryString();
    var departmentId = queryString["departmentId"];
    if(!departmentId){
    	alert("条件不符合，没有部门ID!");
	    location.href="../Login.aspx";
	    return;
    }
	$(".STYLE4").wrap("<a href='../ZP/SelfExaminationView.aspx?DepartID={0}'></a>".format(departmentId));
	$("#newCq").click(function(){
		location.href="Illustrativecase.aspx?departmentId={0}".format(departmentId);	   
	});
	$.ajax({
	    url:"ashx/load_illustrativecase_list.ashx",
	    data:"departmentId={0}".format(departmentId),
		cache:false,
	    success:function(data){
	        data = nehnre.parseJSON(data);
	        if(data){
				var tr = $(".model");
	            $.each(data,function(i,v){
	                var onerow = tr.clone();
					var children = onerow.children();
					children.eq(0).html(i + 1);
					children.eq(2).html(v.caseReason);
					children.eq(4).find("a").attr("href","Illustrativecase.aspx?departmentId={0}&ilId={1}".format(departmentId, v.ilId));
					children.eq(5).find("a").attr("href","ashx/DeleteIllustrativecase.ashx?departmentId={0}&ilId={1}".format(departmentId, v.ilId));
                    onerow.removeClass("model");
                    onerow.addClass("model1");
                    if($(".model1").size() > 0){
                        $(".model1").last().after(onerow);
                    } else {
                        $(".model").last().after(onerow)
                    }
	            });
	        } else {
	            alert("加载数据出错！");
	        }
	    }
	});   
	
	$.ajax({
	    url:"ashx/load_depart_by_id.ashx",
	    data:"departmentId={0}".format(departmentId),
		cache:false,
	    success:function(data){
	        $("#departmentName").html(data);
	    }
	});	
});